import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
// 登录成功以后的页面 ,一级路由全都是Layout
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '主页', icon: 'dashboard' }
    }]
  },
// 商品管理
  {
    path: '/commodity',
    component: Layout,
  	alwaysShow: true,
    redirect: '/commodity/list',
    name: 'commodity',
    meta: { title: '商品管理', icon: 'el-icon-s-cooperation' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/commodity/list/index'),
        meta: { title: '商品列表', icon: 'el-icon-goods'}
      },
	  {
	    path: 'classify',
	    name: 'Classify',
	    component: () => import('@/views/commodity/classify/index'),
	    meta: { title: '商品分类', icon: 'el-icon-menu' }
	  },
		{
		  path: 'administration',
		  name: 'Administration',
		  component: () => import('@/views/commodity/administration/index'),
		  meta: { title: '品牌管理', icon: 'el-icon-suitcase-1' }
		},
  	 // 新增商品
  	  {
  	    path: 'addCommodity',
  	  hidden: true   ,  //隐藏侧边栏
  	    name: 'AddCommodity',
  	    component: () => import('@/views/commodity/list/addCommodity/index'),
  	    meta: { title: '新增商品',
  	 icon: 'table' , 
  	 activeMenu: '/commodity/list' }//侧边栏高亮 
  	  },
	  // 编辑商品
	  {
	     path: 'eddCommodity',
	   hidden: true   ,  //隐藏侧边栏
	     name: 'EddCommodity',
	     component: () => import('@/views/commodity/list/addCommodity/index'),	
	     meta: { title: '编辑商品',
	  icon: 'table' , 
	  activeMenu: '/commodity/list' }//侧边栏高亮 
	   }
  	  
    ],
  },
	
	// 订单管理
	// 商品管理
	  {
	    path: '/order',
	    component: Layout,
	  	alwaysShow: true,
	    redirect: '/order/list',
	    name: 'Order',
	    meta: { title: '订单管理', icon: 'el-icon-tickets' },
	    children: [
	      {
	        path: 'list',
	        name: 'List',
	        component: () => import('@/views/order/list/index'),
	        meta: { title: '订单列表', icon: 'el-icon-document-checked'}
	      },
		  {
		    path: 'back',
		    name: 'Back',
		    component: () => import('@/views/order/back/index'),
		    meta: { title: '退单列表', icon: 'el-icon-document-delete' }
		  },
			{
			  path: 'address',
			  name: 'Address',
			  component: () => import('@/views/order/address/index'),
			  meta: { title: '地址管理', icon: 'el-icon-office-building' }
			},
	  	 // 订单详情
	  	  {
	  	    path: 'orderInfo/:id',
	  	  hidden: true   ,  //隐藏侧边栏
	  	    name: 'OrderInfo',
	  	    component: () => import('@/views/order/list/orderInfo/index'),
	  	    meta: { title: '订单详情',
	  	 icon: 'table' , 
	  	 activeMenu: '/order/list' }//侧边栏高亮 
	  	  },
		  // 退单详情
		  {
		     path: 'detail/:id',
		   hidden: true   ,  //隐藏侧边栏
		     name: 'Detail',
		     component: () => import('@/views/order/back/detail/index'),	
		     meta: { title: '订单详情',
		  icon: 'table' , 
		  activeMenu: '/order/back' }//侧边栏高亮 
		   }
	  	  
	    ],
	  },










  {
    path: '/content',
    component: Layout,
	alwaysShow: true,
    redirect: '/content/article',
    name: 'Content',
    meta: { title: '内容管理', icon: 'el-icon-files' },
    children: [
      {
        path: 'article',
        name: 'Article',
        component: () => import('@/views/content/article/index'),
        meta: { title: '文章管理', icon: 'table' }
      },
	  // 素材管理
	  {
	    path: 'material',
	    name: 'Material',
	    component: () => import('@/views/content/material/index'),
	    meta: { title: '素材管理', icon: 'el-icon-picture' }
	  },
			// 新增文章
     {
       path: 'detail',
	   hidden: true   ,  //隐藏侧边栏
       name: 'Detail',
       component: () => import('@/views/content/article/detail/index'),
       meta: { title: '新增文章',
		icon: 'table' , 
		activeMenu: '/content/article' }//侧边栏高亮 
     },
		 // 编辑文章
		 {
		    path: 'eddetail/:id',
		  hidden: true   ,  //隐藏侧边栏
		    name: 'EDDetail',
		    component: () => import('@/views/content/article/detail/index'),
		    meta: { title: '编辑文章',
		 icon: 'table' , 
		 activeMenu: '/content/article' }//侧边栏高亮 
		  }
    ],
  },
// 注册用户管理
 {
   path: '/registeredUsers',
   component: Layout,
 	alwaysShow: true,
   redirect: '/registeredUsers/ListUsers',
   name: 'RegisteredUsers',
   meta: { title: '注册用户管理', icon: 'el-icon-s-custom' },
   children: [
     {
       path: 'listUsers',
       name: 'ListUsers',
       component: () => import('@/views/RegisteredUsers/ListUsers/index'),
       meta: { title: '用户列表', icon: 'el-icon-s-custom' }
     },
 	 
 	  
   ],
 },
// 营销管理
  {
    path: '/marketing',
    component: Layout,
  	alwaysShow: true,
    redirect: '/marketing/time',
    name: 'RegisteredUsers',
    meta: { title: '营销管理', icon: 'el-icon-s-goods' },
    children: [
      {
        path: 'time',
        name: 'Time',
        component: () => import('@/views/marketing/time/index'),
        meta: { title: '限时活动', icon: 'el-icon-message-solid' }
      },
	  {
	    path: 'advertising',
	    name: 'Advertising',
	    component: () => import('@/views/marketing/advertising/index'),
	    meta: { title: '广告列表', icon: 'el-icon-s-order' }
	  },
  	 
  	  
    ],
  },
	
// 个人中心
{
    path: '/core',
    component: Layout,
  	alwaysShow: true,
    redirect: '/core/home',
    name: 'Core',
    meta: { title: '个人中心', icon: 'el-icon-user' },
    children: [
      {
        path: 'home',
        name: 'Home',
        component: () => import('@/views/core/home/index'),
        meta: { title: '个人主页', icon: 'el-icon-user' }
      },
	  {
	    path: 'set',
	    name: 'Set',
	    component: () => import('@/views/core/set/index'),
	    meta: { title: '个人设置', icon: 'el-icon-setting' }
	  },
  	 
  	  
    ],
  },

// 个人设置
{
    path: '/personageSet',
    component: Layout,
  	alwaysShow: true,
    // redirect: '/personageSet/index',
    name: 'PersonageSet',
    meta: { title: '个人设置', icon: 'el-icon-setting' },
    
  },









  

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({ 
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
